package com.ssh.web;

import java.util.List;

import javax.servlet.ServletContext;

import org.apache.struts2.ServletActionContext;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import com.opensymphony.xwork2.ActionSupport;
import com.ssh.model.Contenttype;
import com.ssh.service.ContenttypeService;
import com.ssh.service.IContenttypeService;

public class ContenttypeAction extends ActionSupport {
	private IContenttypeService contenttypeService=null ;

	public void setContenttypeService(IContenttypeService contenttypeService) {
		this.contenttypeService = contenttypeService;
	}
			
	
	public IContenttypeService getContenttypeService(){
    	if(contenttypeService ==null){
    		ServletContext sc=ServletActionContext.getServletContext();
    		ApplicationContext ac=WebApplicationContextUtils.getRequiredWebApplicationContext(sc);
    		contenttypeService =(IContenttypeService)ac.getBean("contenttypeService");
    		if(contenttypeService==null)
    			System.out.println("error");
    	}
    	return contenttypeService;
    }
	
	public void findAll(){
		List<Contenttype> list=contenttypeService.findAll();
		for(Contenttype l:list){
			System.out.println(l.getTypename());
		}
	}

}
